#include "pfdr.h"
#include "FM25V01.h"
#include "sysconf.h"

uint8_t g_pfdr_buffer[DB_ZIP_ALL] = {0};
void    pfdr_write(void) {
  uint16_t buf_offset = 0; /*偏移地址 */
  DB0_pack_to_buffer(g_pfdr_buffer + buf_offset, DB0_ZIP_SIZE);
  buf_offset += DB0_ZIP_SIZE;
  DB1_pack_to_buffer(g_pfdr_buffer + buf_offset, DB1_ZIP_SIZE);
  buf_offset += DB1_ZIP_SIZE;
  DB22_pack_to_buffer(g_pfdr_buffer + buf_offset, DB22_ZIP_SIZE);
  buf_offset += DB22_ZIP_SIZE;
  DB52_pack_to_buffer(g_pfdr_buffer + buf_offset, DB52_ZIP_SIZE);
  buf_offset += DB52_ZIP_SIZE;
  DB81_pack_to_buffer(g_pfdr_buffer + buf_offset, DB81_ZIP_SIZE);
  buf_offset += DB81_ZIP_SIZE;
  DB91_pack_to_buffer(g_pfdr_buffer + buf_offset, DB91_ZIP_SIZE);
  buf_offset += DB91_ZIP_SIZE;
  DB101_pack_to_buffer(g_pfdr_buffer + buf_offset, DB101_ZIP_SIZE);
  buf_offset += DB101_ZIP_SIZE;
  DB110_pack_to_buffer(g_pfdr_buffer + buf_offset, DB110_ZIP_SIZE);
  buf_offset += DB110_ZIP_SIZE;
  FM25V01_WRITE(DB_PFDR_ADDR, g_pfdr_buffer, DB_ZIP_ALL);
}
void pfdr_read(void) {
  FM25V01_READ(DB_PFDR_ADDR, g_pfdr_buffer, DB_ZIP_ALL);
  uint16_t buf_offset = 0; /*偏移地址 */
  DB0_unpack_from_buffer(g_pfdr_buffer + buf_offset, DB0_ZIP_SIZE);
  buf_offset += DB0_ZIP_SIZE;
  DB1_unpack_from_buffer(g_pfdr_buffer + buf_offset, DB1_ZIP_SIZE);
  buf_offset += DB1_ZIP_SIZE;
  DB22_unpack_from_buffer(g_pfdr_buffer + buf_offset, DB22_ZIP_SIZE);
  buf_offset += DB22_ZIP_SIZE;
  DB52_unpack_from_buffer(g_pfdr_buffer + buf_offset, DB52_ZIP_SIZE);
  buf_offset += DB52_ZIP_SIZE;
  DB81_unpack_from_buffer(g_pfdr_buffer + buf_offset, DB81_ZIP_SIZE);
  buf_offset += DB81_ZIP_SIZE;
  DB91_unpack_from_buffer(g_pfdr_buffer + buf_offset, DB91_ZIP_SIZE);
  buf_offset += DB91_ZIP_SIZE;
  DB101_unpack_from_buffer(g_pfdr_buffer + buf_offset, DB101_ZIP_SIZE);
  buf_offset += DB101_ZIP_SIZE;
  DB110_unpack_from_buffer(g_pfdr_buffer + buf_offset, DB110_ZIP_SIZE);
  buf_offset += DB110_ZIP_SIZE;
}